<template>
	<view class="uiwu">
		<uiwu-list :loading="more">
			<view class="uiwu-list">
				<view class="uiwu-list-item" v-for="(item, index) in listData" :key="index">
					<view class="time">{{ item.add_time }}</view>
					<view class="itiem uiwu-flex-space flex justify-between">
						<text class="title">{{ item.title }}</text>
						<text class="tips" :class="item.pm == 0 ? 'active' : ''">{{ item.pm == 0 ? '-' :
							'+' }}{{ item.number }}</text>
					</view>
				</view>
			</view>
		</uiwu-list>
	</view>
</template>

<script setup lang="ts">
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { ref } from 'vue';
import { moneylist, uiwu } from '@/api/interface/interface';
const listData = ref<Array<object>>([])
const pageNum = ref<number>(1)
const more = ref<string>('loading');
const isLock = ref<boolean>(true)
const getmoneylist = async (mack: boolean = false): Promise<any> => {
	if (!mack) pageNum.value = 1
	const { data: { data, total } } = await moneylist({
		page: pageNum.value
	});
	isLock.value = true
	uiwu.setlist({
		isMore: mack,
		listData,
		total,
		listRow: data,
		more,
		pageNum
	})
}
/**
 * 加载更多
 */
onReachBottom(() => {
	if (!isLock.value) return
	isLock.value = false
	pageNum.value++
	getmoneylist(true)
})
onLoad(() => {
	getmoneylist()
})
</script>

<style lang="scss">
page {
	background-color: #F6F6F6;
}

.uiwu-list {
	&-item {
		.time {
			font-size: 24rpx;
			font-weight: 400;
			color: #444444;
			line-height: 72rpx;
			padding: 0 24rpx;
		}

		.itiem {
			background-color: #fff;
			padding: 32rpx 24rpx;
			border-bottom: 1rpx solid #E6E6E6;

			&:last-child {
				border-bottom: 0;
			}

			.title {
				font-size: 28rpx;
				font-weight: 800;
				color: #231815;
			}

			.tips {
				font-size: 28rpx;
				font-weight: 500;
				color: #5BB431;

				&.active {
					color: rgba(230, 0, 18, 1);
				}
			}
		}
	}
}
</style>
